/*
 * MemorySequence.java
 *
 * Created on February 26, 2007, 2:02 PM
 *
 * (C) R. Alexander Milowski alex@milowski.com
 */

package org.infoset.xml.memory;

import java.util.ArrayList;
import java.util.List;
import org.infoset.xml.Infoset;
import org.infoset.xml.Item;
import org.infoset.xml.Sequence;

/**
 *
 * @author R. Alexander Milowski
 */
public class MemorySequence extends MemoryItem implements Sequence {
   
   List<Item> contents;
   
   /** Creates a new instance of MemorySequence */
   public MemorySequence(Infoset infoset) {
      super(infoset,0,null);
      this.contents = null;
   }
   
   public Item.ItemType getType() {
      return Item.ItemType.SequenceItem;
   }
   
   protected void setIndex(int i) {}
   
   public Item copyOfItem(boolean deep) {
      // immutable so return self
      return this;
   }
   
   public boolean hasContent() {
      return contents!=null && contents.size()!=0;
   }
   
   public List<Item> getContents() {
      if (contents==null) {
         contents = new ArrayList<Item>();
      }
      return contents;
   }
   
}
